<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>11.css实现input搜索框展开动画3</title>
  </head>
  <link rel="stylesheet" href="../common.css" />
  <style>
    .input-boxLine {
      width: 160px;
      height: 40px;
      margin-top: 10px;
      position: relative;
    }
    .input-boxLine input {
      width: 100%;
      height: 100%;
      font-size: 17px;
      border-bottom: 1px solid #afaebd;
      color: #fff;
      font-style: italic;
      text-transform: uppercase;
      letter-spacing: 5px;
    }
    .input-boxLine span {
      position: absolute;
      bottom: 10px;
      left: 0;
      color: #afaebd;
      pointer-events: none;
      /* 过渡效果 */
      transition: all 0.3s ease;
    }
    .input-boxLine .line {
      position: absolute;
      bottom: 0;
      height: 2px;
      width: 100%;
      background-color: #ffaa7f;
      /* x的宽度缩小为0 */
      transform: scaleX(0);
      /* 过渡效果 */
      transition: all 0.3s ease;
    }
    .input-boxLine input:focus ~ span,
    .input-boxLine input:valid ~ span {
      top: -10px;
      font-size: 12px;
      color: #ffaa7f;
      font-style: oblique;
    }
    .input-boxLine input:focus ~ .line,
    .input-boxLine input:valid ~ .line {
      transform: scale(1);
    }
  </style>
  <body>
    <div class="input-boxLine">
      <!-- required属性 规定必需在提交之前填写输入字段 -->
      <input type="text" required />
      <!-- 线条 -->
      <div class="line"></div>
      <span>请输入搜索内容</span>
    </div>
  </body>
</html>
